<template>
  <div class="content">
    <el-form ref="form" :model="form">
      <div class="search">
        <el-form-item label="提问时间" class="label" style="padding-top:12px;">
          <el-date-picker
            class="input"
            v-model="form.time"
            type="datetimerange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="问题类型" class="label">
          <el-select placeholder="请选择问题类型" class="input" v-model="form.type">
            <el-option v-for="item in typeoptions"
                :key="item.value"
                :label="item.label"
                :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
         <el-form-item label="处理状态" class="label">
          <el-select placeholder="请输入处理状态" class="input" v-model="form.status">
             <el-option v-for="item in statusoptions"
                :key="item.value"
                :label="item.label"
                :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onSubmit" size="mini">查询</el-button>
        </el-form-item>
      </div>
    </el-form>
    <el-table
      ref="singleTable"
      :data="tableData"
      :header-cell-style="{background: '#EBECF0',height:'44px',color:'#000000'}"
      :cell-style="{background: '#ffffff',height:'44px',color:'#000000'}"
      highlight-current-row
      style="width: 100%"
     >
      <el-table-column label="序号" type="index" :index="indexMethod" width="100"></el-table-column>
      <el-table-column property="createtime" label="提问时间" ></el-table-column>
      <el-table-column property="type"  label="问题类型">
        <template slot-scope="scope">
          <el-link :type="scope.row.type=='0'?'primary':scope.row.type=='1'?'warning':'danger'" :underline="false">
            {{scope.row.type=='0'?'咨询':scope.row.type=='1'?'建议':'投诉'}}
          </el-link>
        </template>
      </el-table-column>
      <el-table-column property="creater" label="发起人"></el-table-column>
      <el-table-column property="room" label="房屋信息"></el-table-column>
      <el-table-column property="status" label="处理状态">
        <template slot-scope="scope">
          <el-link :type="scope.row.status=='0'?'danger':'success'" :underline="false">{{scope.row.status=='0'?'未处理':'已处理'}}</el-link>
        </template>
      </el-table-column>
      <el-table-column property="reviewer"  label="处理人"></el-table-column>
      <el-table-column property="updatetime" label="处理时间"></el-table-column>
      <el-table-column property="address" label="操作"  width="100">
        <template slot-scope="scope">
          <el-button type="text" @click="handleClick(scope.row)">{{scope.row.status=='0'?'处理':'查看'}}</el-button>
        </template>
      </el-table-column>
    </el-table>
    <div class="pagination">
      <el-pagination
        :current-page.sync="page"
        background
        :page-sizes="[10, 20, 30, 40]"
        :page-size="pageSize"
        layout="total, prev, pager, next, jumper"
        :total="total"
        @current-change="handleCurrentChange"
      />
    </div>
      <!-- 详情 -->
    <el-dialog width="60%" title :visible.sync="detailVisible">
      <div class="dialog_box">
        <div class="dialog_content">
          <div class="dialog_title">问题信息</div>

          <el-form ref="form" :inline="true" :model="detail">
            <el-row :gutter="20">
              <el-col :span="10">
                <el-form-item label="提问时间" class="label">
                  <el-input v-model="detail.createtime" class="input"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="10" :offset="4">
                <el-form-item label="问题类型" class="label">
                  <el-input v-model="detail.typename" class="input">
                  </el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row :gutter="20">
              <el-col :span="10">
                <el-form-item label="发起人" class="label">
                  <el-input v-model="detail.creater" class="input"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="10" :offset="4">
                <el-form-item label="房屋信息" class="label">
                  <el-input v-model="detail.room" class="input"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
              <el-row :gutter="20">
              <el-col :span="24">

                <div class="label" style="font-size: 14px;color: #606266;font-weight:500;margin-bottom:10px;">
                  问题详情
                </div>
                  <el-input
                    type="textarea"
                    class="input1"
                    :autosize="{ minRows: 4, maxRows: 5}"
                    placeholder="请输入内容"
                    v-model="detail.des">
                  </el-input>
              </el-col>
            </el-row>

            <div class="dialog_title" style="margin-top:20px;">问题回答</div>
            <el-row :gutter="20">
              <el-col :span="10">
                <el-form-item label="处理人" class="label">
                  <el-input v-model="detail.reviewer" class="input"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="10" :offset="4">
                <el-form-item label="处理时间" class="label">
                  <el-input v-model="detail.updatetime" class="input"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
              <el-row :gutter="20">
              <el-col :span="24">

                <div class="label" style="font-size: 14px;color: #606266;font-weight:500;margin-bottom:10px;">
                  问题回复
                </div>
                  <el-input
                    type="textarea"
                    class="input1"
                    :autosize="{ minRows: 4, maxRows: 5}"
                    placeholder="请输入内容"
                    v-model="detail.reviewcontent">
                  </el-input>
              </el-col>
            </el-row>


          </el-form>

        </div>
      </div>
       <span slot="footer" class="dialog-footer">
            <el-button @click="detailVisible = false">关闭</el-button>
          </span>
    </el-dialog>
    <!-- 回复 -->
     <el-dialog width="60%" title :visible.sync="reviewVisible">
       <div class="dialog_box">
        <div class="dialog_content">
          <div class="dialog_title">问题信息</div>

          <el-form ref="form" :inline="true" :model="detail">
            <el-row :gutter="20">
              <el-col :span="10">
                <el-form-item label="提问时间" class="label">
                  <el-input v-model="detail.createtime" class="input"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="10" :offset="4">
                <el-form-item label="问题类型" class="label">
                  <el-input v-model="detail.typename" class="input">
                  </el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row :gutter="20">
              <el-col :span="10">
                <el-form-item label="发起人" class="label">
                  <el-input v-model="detail.creater" class="input"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="10" :offset="4">
                <el-form-item label="房屋信息" class="label">
                  <el-input v-model="detail.room" class="input"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
              <el-row :gutter="20">
              <el-col :span="24">

                <div class="label" style="font-size: 14px;color: #606266;font-weight:500;margin-bottom:10px;">
                  问题详情
                </div>
                  <el-input
                    type="textarea"
                    class="input1"
                    :autosize="{ minRows: 4, maxRows: 5}"
                    placeholder="请输入内容"
                    v-model="detail.des">
                  </el-input>
              </el-col>
            </el-row>

            <div class="dialog_title" style="margin-top:20px;">问题回答</div>
              <el-row :gutter="20">
              <el-col :span="24">

                <div class="label" style="font-size: 14px;color: #606266;font-weight:500;margin-bottom:10px;">
                  问题回复
                </div>
                  <el-input
                    type="textarea"
                    class="input1"
                    :autosize="{ minRows: 4, maxRows: 5}"
                    placeholder="请输入内容"
                    v-model="detail.reviewcontent">
                  </el-input>
              </el-col>
            </el-row>


          </el-form>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
            <el-button type="primary"  @click="reviewVisible = false">提交</el-button>
            <el-button  @click="reviewVisible = false">关闭</el-button>
          </span>
    </el-dialog>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
import ImgDialog from "@/components/Imgdialog";

export default {
  name: "Dashboard",
  data() {
    return {
      form: {
        time:null,
        type:null,
        status:null
      },
      tableData: [
        {
          creater: "张扬阳",
          type: "1",
          room: "新丰苑三期 1-301",
          status: "1",
          createtime: "2020-10-23 12:23:12",
          updatetime:"2020-10-23 12:23:12",
          reviewer: "周华东",
          des:'为什么微信申请后去审核通过了，人脸识别还是刷不了呢',
          reviewcontent:'重新审核一遍'
        },
        {
         creater: "张扬阳",
          type: "2",
          room: "新丰苑三期 1-301",
          status: "0",
          createtime: "2020-10-23 12:23:12",
          des:'为什么微信申请后去审核通过了，人脸识别还是刷不了呢',
          // updatetime:"2020-10-23 12:23:12",
          // reviewer: "周华东"
        }
      ],
      total: 100,
      page: 10,
      pageSize: 10,
      detailVisible: false,
      reviewVisible:false,
      detail: {},
      statusoptions:[
        {label:'全部',value:''},
        {label:'未处理',value:'0'},
        {label:'已处理',value:'1'}
        ],
      typeoptions:[
        {label:'全部',value:''},
        {label:'咨询',value:'0'},
        {label:'建议',value:'1'},
        {label:'投诉',value:'2'},
      ]
    };
  },
  components: {
    ImgDialog
  },
  computed: {
    ...mapGetters(["communityId"]),
    indexMethod(index) {
      return (this.page - 1) * 10 + index + 1;
    }
  },
  created() {},
  methods: {
    handleCurrentChange(val) {
      this.page = val;
    },
    handleClick(row) {
      this.detail = JSON.parse(JSON.stringify(row));
      this.detail.typename=this.detail.type=='0'?'咨询':this.detail.type=='1'?'建议':'投诉'
      if(row.status=='0'){
        //处理
        this.reviewVisible=true
      }else{
        this.detailVisible=true;
      }
      // this.dialogFormVisible = true;
    }
  },
  watch: {
    communityId(newVal, oldVal) {
      console.log("changed");
    }
  }
};
</script>
<style lang="scss" scoped>
.content {
  background: #ffffff;
  padding: 25px;
  padding-bottom: 100px;
  min-height: 800px;
  position: relative;
  .search {
    display: flex;
    align-items: flex-end;
    border-bottom: 2px solid #dcdee3;
    margin-bottom: 30px;
  }
  .input {
    width: 346px;
  }
    .input1 {
    width: 100%;
  }
  .label{
    margin-right: 20px;
    color: #666666;
    font-size: 14px;
  }
  .pagination {
    position: absolute;
    right: 0;
    bottom: 0;
    margin: 50px;
  }
  .img {
    width: 50px;
    height: 34px;
  }
}
</style>
<style>
.input .el-input__inner {
  height: 28px !important;
}
.el-date-editor {
  /* margin-top: px !important; */
  height: 32px !important;
}
.el-textarea__inner{
  width: 100%;
}
</style>
